package com.fr.report;

import com.fr.base.ColumnRow;
import com.fr.base.XMLable;
import com.fr.base.background.Background;
import com.fr.base.background.ColorBackground;
import com.fr.base.xml.BaseXMLUtils;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import java.awt.Color;
import java.io.Serializable;

public class ReportSettings
  implements XMLable, Cloneable, Serializable
{
  public static final ReportSettings DEFAULTSETTINGS = new ReportSettings();
  public static final int DEFAULT_RESOLUTION = 96;
  private static final long serialVersionUID = -3314213013399129839L;
  public static final String XML_TAG = "ReportSettings";
  private int orientation = 0;
  private PaperSize paperSize = new PaperSize();
  private Margin margin = new Margin(0.27D, 0.75D, 0.27D, 0.75D);
  private boolean lonelyPage = false;

  /**
   * @deprecated
   */
  private int resolution = 96;
  private int pageOrder = 0;
  private boolean isHorizontalCenterOnPage = false;
  private boolean isVerticalCenterOnPage = false;
  private int firstPageNumber = 1;
  private Background background = ColorBackground.getInstance(Color.white);
  private boolean isPreviewBackground = true;
  private boolean isPrintBackground = true;
  private ColumnRow writeFrozenColumnRow;
  private double headerHeight = 0.0D;
  private double footerHeight = 0.0D;
  private int shrinkToFitMode = 1;

  public ColumnRow getWriteFrozenColumnRow()
  {
    return this.writeFrozenColumnRow;
  }

  public void setWriteFrozenColumnRow(ColumnRow paramColumnRow)
  {
    this.writeFrozenColumnRow = paramColumnRow;
  }

  public boolean isLonelyPage()
  {
    return this.lonelyPage;
  }

  public void setLonelyPage(boolean paramBoolean)
  {
    this.lonelyPage = paramBoolean;
  }

  public int getOrientation()
  {
    return this.orientation;
  }

  public void setOrientation(int paramInt)
  {
    this.orientation = paramInt;
  }

  public PaperSize getPaperSize()
  {
    return this.paperSize;
  }

  public void setPaperSize(PaperSize paramPaperSize)
  {
    this.paperSize = paramPaperSize;
  }

  public Margin getMargin()
  {
    return this.margin;
  }

  public void setMargin(Margin paramMargin)
  {
    this.margin = paramMargin;
  }

  /**
   * @deprecated
   */
  public int getResolution()
  {
    return this.resolution;
  }

  /**
   * @deprecated
   */
  public void setResolution(int paramInt)
  {
    this.resolution = paramInt;
  }

  public int getPageOrder()
  {
    return this.pageOrder;
  }

  public void setPageOrder(int paramInt)
  {
    this.pageOrder = paramInt;
  }

  public int getShrinkToFitMode()
  {
    return this.shrinkToFitMode;
  }

  public void setShrinkToFitMode(int paramInt)
  {
    this.shrinkToFitMode = paramInt;
  }

  public boolean isHorizontalCenterOnPage()
  {
    return this.isHorizontalCenterOnPage;
  }

  public void setHorizontalCenterOnPage(boolean paramBoolean)
  {
    this.isHorizontalCenterOnPage = paramBoolean;
  }

  public boolean isVerticalCenterOnPage()
  {
    return this.isVerticalCenterOnPage;
  }

  public void setVerticalCenterOnPage(boolean paramBoolean)
  {
    this.isVerticalCenterOnPage = paramBoolean;
  }

  public int getFirstPageNumber()
  {
    return this.firstPageNumber;
  }

  public void setFirstPageNumber(int paramInt)
  {
    this.firstPageNumber = paramInt;
  }

  public Background getBackground()
  {
    return this.background;
  }

  public void setBackground(Background paramBackground)
  {
    this.background = paramBackground;
  }

  public boolean isPreviewBackground()
  {
    return this.isPreviewBackground;
  }

  public void setPreviewBackground(boolean paramBoolean)
  {
    this.isPreviewBackground = paramBoolean;
  }

  public boolean isPrintBackground()
  {
    return this.isPrintBackground;
  }

  public void setPrintBackground(boolean paramBoolean)
  {
    this.isPrintBackground = paramBoolean;
  }

  public double getHeaderHeight()
  {
    return this.headerHeight;
  }

  public void setHeaderHeight(double paramDouble)
  {
    this.headerHeight = paramDouble;
  }

  public double getFooterHeight()
  {
    return this.footerHeight;
  }

  public void setFooterHeight(double paramDouble)
  {
    this.footerHeight = paramDouble;
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    String str1;
    if (paramXMLableReader.isAttr())
    {
      if ((str1 = paramXMLableReader.getAttr("firstPageNumber")) != null)
        setFirstPageNumber(Integer.parseInt(str1));
      if ((str1 = paramXMLableReader.getAttr("orientation")) != null)
        setOrientation(Integer.parseInt(str1));
      if ((str1 = paramXMLableReader.getAttr("resolution")) != null)
        setResolution(Integer.parseInt(str1));
      if ((str1 = paramXMLableReader.getAttr("pageOrder")) != null)
        setPageOrder(Integer.parseInt(str1));
      if ((str1 = paramXMLableReader.getAttr("shrinkToFit")) != null)
        setShrinkToFitMode((Boolean.valueOf(str1).booleanValue()) ? 1 : 0);
      if ((str1 = paramXMLableReader.getAttr("shrinkToFitMode")) != null)
        setShrinkToFitMode(Integer.parseInt(str1));
      if ((str1 = paramXMLableReader.getAttr("isLonelyPage")) != null)
        setLonelyPage(Boolean.valueOf(str1).booleanValue());
      if ((str1 = paramXMLableReader.getAttr("isHorizontalCenterOnPage")) != null)
        setHorizontalCenterOnPage(Boolean.valueOf(str1).booleanValue());
      if ((str1 = paramXMLableReader.getAttr("isVerticalCenterOnPage")) != null)
        setVerticalCenterOnPage(Boolean.valueOf(str1).booleanValue());
      if ((str1 = paramXMLableReader.getAttr("firstPageNumber")) != null)
        setFirstPageNumber(Integer.parseInt(str1));
      if ((str1 = paramXMLableReader.getAttr("headerHeight")) != null)
        setHeaderHeight(Double.parseDouble(str1));
      if ((str1 = paramXMLableReader.getAttr("footerHeight")) != null)
        setFooterHeight(Double.parseDouble(str1));
      if ((str1 = paramXMLableReader.getAttr("previewBackground")) != null)
        setPreviewBackground(Boolean.valueOf(str1).booleanValue());
      if ((str1 = paramXMLableReader.getAttr("printBackground")) != null)
        setPrintBackground(Boolean.valueOf(str1).booleanValue());
    }
    if (paramXMLableReader.isChildNode())
    {
      Object localObject;
      String str2 = paramXMLableReader.getTagName();
      if (str2.equals("PaperSize"))
      {
        localObject = getPaperSize();
        if (localObject == null)
        {
          localObject = new PaperSize();
          setPaperSize((PaperSize)localObject);
        }
        if ((str1 = paramXMLableReader.getAttr("width")) != null)
          ((PaperSize)localObject).setWidth(Double.parseDouble(str1));
        if ((str1 = paramXMLableReader.getAttr("height")) != null)
          ((PaperSize)localObject).setHeight(Double.parseDouble(str1));
      }
      else if (str2.equals("Margin"))
      {
        localObject = getMargin();
        if (localObject == null)
        {
          localObject = new Margin();
          setMargin((Margin)localObject);
        }
        if ((str1 = paramXMLableReader.getAttr("top")) != null)
          ((Margin)localObject).setTop(Double.parseDouble(str1));
        if ((str1 = paramXMLableReader.getAttr("left")) != null)
          ((Margin)localObject).setLeft(Double.parseDouble(str1));
        if ((str1 = paramXMLableReader.getAttr("bottom")) != null)
          ((Margin)localObject).setBottom(Double.parseDouble(str1));
        if ((str1 = paramXMLableReader.getAttr("right")) != null)
          ((Margin)localObject).setRight(Double.parseDouble(str1));
      }
      else if (str2.equals("Background"))
      {
        setBackground(BaseXMLUtils.readBackground(paramXMLableReader));
      }
      else if (paramXMLableReader.getTagName().equals("FrozenColumnRow"))
      {
        if ((str1 = paramXMLableReader.getAttr("columnrow")) != null)
        {
          localObject = ColumnRow.valueOf(str1);
          if (ColumnRow.validate((ColumnRow)localObject))
            setWriteFrozenColumnRow((ColumnRow)localObject);
        }
      }
    }
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    paramXMLPrintWriter.startTAG("ReportSettings");
    if (getFirstPageNumber() != 1)
      paramXMLPrintWriter.attr("firstPageNumber", getFirstPageNumber());
    if (getOrientation() != 0)
      paramXMLPrintWriter.attr("orientation", getOrientation());
    if (getResolution() != 96)
      paramXMLPrintWriter.attr("resolution", getResolution());
    if (getPageOrder() != 0)
      paramXMLPrintWriter.attr("paegOrder", getPageOrder());
    if (this.shrinkToFitMode != 1)
      paramXMLPrintWriter.attr("shrinkToFitMode", getShrinkToFitMode());
    if (isLonelyPage())
      paramXMLPrintWriter.attr("isLonelyPage", isLonelyPage());
    if (isHorizontalCenterOnPage())
      paramXMLPrintWriter.attr("isHorizontalCenterOnPage", isHorizontalCenterOnPage());
    if (isVerticalCenterOnPage())
      paramXMLPrintWriter.attr("isVerticalCenterOnPage", isVerticalCenterOnPage());
    if (getHeaderHeight() != 0.53D)
      paramXMLPrintWriter.attr("headerHeight", getHeaderHeight());
    if (getFooterHeight() != 0.53D)
      paramXMLPrintWriter.attr("footerHeight", getFooterHeight());
    if (!(isPrintBackground()))
      paramXMLPrintWriter.attr("printBackground", isPrintBackground());
    if (ColumnRow.validate(this.writeFrozenColumnRow))
      paramXMLPrintWriter.startTAG("FrozenColumnRow").attr("columnrow", this.writeFrozenColumnRow.toString()).end();
    PaperSize localPaperSize = getPaperSize();
    if ((localPaperSize != null) && (!(localPaperSize.equals(PaperSize.PAPERSIZE_A4))))
      paramXMLPrintWriter.startTAG("PaperSize").attr("width", localPaperSize.getWidth()).attr("height", localPaperSize.getHeight()).end();
    Margin localMargin = getMargin();
    if ((localMargin != null) && (((localMargin.getTop() != 0.47D) || (localMargin.getLeft() != 0.75D) || (localMargin.getBottom() != 0.47D) || (localMargin.getRight() != 0.75D))))
      paramXMLPrintWriter.startTAG("Margin").attr("top", localMargin.getTop()).attr("left", localMargin.getLeft()).attr("bottom", localMargin.getBottom()).attr("right", localMargin.getRight()).end();
    Background localBackground = getBackground();
    if (!(ColorBackground.getInstance(Color.white).equals(localBackground)))
      BaseXMLUtils.writeBackground(paramXMLPrintWriter, localBackground);
    paramXMLPrintWriter.end();
  }

  public Object clone()
    throws CloneNotSupportedException
  {
    ReportSettings localReportSettings = (ReportSettings)super.clone();
    localReportSettings.setPaperSize((PaperSize)getPaperSize().clone());
    localReportSettings.setMargin((Margin)getMargin().clone());
    if (this.writeFrozenColumnRow != null)
      localReportSettings.setWriteFrozenColumnRow((ColumnRow)this.writeFrozenColumnRow.clone());
    if (getBackground() != null)
      localReportSettings.setBackground((Background)getBackground().clone());
    else
      localReportSettings.setBackground(null);
    return localReportSettings;
  }
}